Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Problem

SSH workspaces are independent git clones. Unlike local worktrees (which share .git), deleting an SSH workspace with unpushed commits permanently loses that work. The deletion code only checked for uncommitted changes, not unpushed refs.

Solution

Added unpushed refs check to SSHRuntime.deleteWorkspace():

  • Checks for unpushed commits when force=false
  • Only checks when git remotes are configured (no remote = no concept of "unpushed")
  • Returns error when unpushed commits exist, requiring force=true to proceed

Performance Optimization

Combined all pre-deletion checks into a single bash script to minimize SSH round trips:

  • Before: 5 separate exec calls (check exists, check dirty, check remotes, check unpushed, delete)
  • After: 2 exec calls (combined checks, delete)
  • Reduction: 60% fewer SSH round trips

Exit code mapping:

  • 0: Safe to delete
  • 1: Uncommitted changes
  • 2: Unpushed commits
  • 3: Doesn't exist (idempotent)

Testing

Added integration tests for SSH workspaces:

  • should fail to delete SSH workspace with unpushed refs without force flag
  • should delete SSH workspace with unpushed refs when force flag is set

All 16 deletion tests pass (9 local + 7 SSH).

Generated with cmux

- Add unpushed refs check to SSHRuntime.deleteWorkspace()
- Only checks when git remotes are configured (no remote = no concept of unpushed)
- Rejects deletion when unpushed commits exist unless force=true
- Optimize: combine all pre-deletion checks into single bash script
- Reduces SSH round trips from 5 to 2 (60% reduction)
- Add tests for unpushed refs protection (force=false and force=true cases)

Generated with `cmux`
- Extract SSH-specific unpushed refs tests into separate describe block
- Removes conditional type checks inside tests (cleaner test structure)
- Test output now clearly separates SSH-only tests from matrix tests
- Follows same pattern as local-only submodule tests
@ammario ammario added this pull request to the merge queue Oct 28, 2025
Merged via the queue into main with commit 9013859 Oct 28, 2025
23 of 25 checks passed
@ammario ammario deleted the unpushed-refs branch October 28, 2025 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants